from pydantic import BaseModel
from typing import Optional, Dict, Any
from datetime import datetime

# Ticket base schema
class TicketBase(BaseModel):
    issue_id: int
    case_id: Optional[int] = None
    template: Optional[Dict[str, Any]] = None
    attachments: Optional[Dict[str, Any]] = None
    status: str

# Ticket creation schema
class TicketCreate(TicketBase):
    pass

# Ticket update schema
class TicketUpdate(BaseModel):
    issue_id: Optional[int] = None
    case_id: Optional[int] = None
    template: Optional[Dict[str, Any]] = None
    attachments: Optional[Dict[str, Any]] = None
    status: Optional[str] = None

# Ticket response schema
class TicketResponse(TicketBase):
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        orm_mode = True